<template>
  <transition name="fade" mode="out-in">
    <div class="index">
      <van-nav-bar
        left-arrow
        @click-left="onClickLeft"
        @click-right="onClickRight"
      >
        <div class="nav-right" slot="right">
          推荐码
        </div>
      </van-nav-bar>
      <van-pull-refresh v-model="isLoading" @refresh="onRefresh" class="content">
        <div class="content-top">
          <div class="content-top-detail">
            <div class="title">
              收益情况(元)
            </div>
            <div class="income">
              <div class="income-item">
                <p class="income-item-title">今日收入</p>
                <p class="income-item-price">¥203.64</p>
              </div>
              <div class="income-item">
                <p class="income-item-title" style="text-align: right;">总收入</p>
                <p class="income-item-price">¥5785.64</p>
              </div>
            </div>
            <img src="@/assets/index/Group.png" class="index-prograss">
          </div>
          <van-cell value="各级分成明细" is-link to="/income" class="index-cell">
            <template slot="title">
              <img src="@/assets/index/icon_shuidi.png" class="cell-icon">
              <span class="custom-text">收入流水</span>
            </template>
          </van-cell>
        </div>

        <section class="content-section">
          <div class="section-title">
            业务发展
          </div>
          <div class="section-container">
            <div class="section-item" @click="jumpTo('/salesman-management')">
              <img src="@/assets/index/icon_salesman.png" class="section-item-img">
              <span class="section-item-txt">业务员管理</span>
            </div>
            <div class="section-item" @click="jumpTo('/divided-management')">
              <img src="@/assets/index/icon_divide.png" class="section-item-img">
              <span class="section-item-txt">分成管理</span>
            </div>
            <div class="section-item" @click="jumpTo('/salesman-add')">
              <img src="@/assets/index/icon_add.png" class="section-item-img">
              <span class="section-item-txt">快速添加</span>
            </div>
          </div>
        </section>

        <section class="content-section">
          <div class="section-title">
            我的客户
            <p class="section-more" @click="jumpTo('/my-client')">
              查看更多
              <img src="@/assets/icon_back.png">
            </p>
          </div>
          <div
            v-for="item in list"
            :key="item"
            class="list-item"
          >
            <div class="list-title">
              <img src="@/assets/index/icon_salesman.png" style="border-radius: 50%;width: 40px;margin-right: 15px;">
              <div class="name">
                {{ item }}
              </div>
            </div>
            <div class="list-price">
              <p class="list-price-top">累计消费(元)</p>
              <p class="list-price-bottom">-62537.37</p>
            </div>
          </div>
        </section>
      </van-pull-refresh>
    </div>
  </transition>
</template>

<script>
import { Button, NavBar, Cell, CellGroup, Icon, PullRefresh, Toast } from 'vant';
export default {
  components: {
    [Button.name]: Button,
    [NavBar.name]: NavBar,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Icon.name]: Icon,
    [PullRefresh.name]: PullRefresh,
    [Toast.name]: Toast,
  },
  data () {
    return {
      isLoading: false,
      list: [1, 2, 3, 4, 5],
    }
  },
  mounted() {

  },
  methods: {
    onClickLeft() {
      // this.$router.go(-1)
      this.$router.push('/')
    },
    onClickRight() {
      // 点击推荐码
      this.$router.push('/referral-code')
    },
    jumpTo(url) {
      this.$router.push(url)
    },
    onRefresh() {
      // 下拉刷新
      setTimeout(() => {
        Toast.success({
          message: '刷新成功',
          duration: 1000
        })
        this.isLoading = false
      }, 500)
    }
  },
}
</script>

<style scoped>
.index {
  height: 100vh;
  overflow: auto;
  background-color: #fff;
  color: #38393A;
}
.van-nav-bar {
  background-color: #fff;
}
.nav-right {
  font-size: 16px;
}
.content {
  padding: 16px 16px 0 16px;
}
.content-top {
  box-shadow: 0px 2px 16px rgba(105, 105, 105, 0.3);
  border-radius: 8px;
  margin-bottom: 20px;
}
.index-prograss {
  width: 100%;
  margin-top: 11px;
}
.cell-icon {
   position: absolute; 
   top: 10px;
   width: 22px;
   margin-right: 5px;
}
.custom-text {
  padding: 0 0 0 26px;
}
.index-cell {
  border-radius: 0 0 8px;
  background-color: #E6EAEE;
  padding: 9px 12px;
}
.content-top-detail {
  padding: 16px;
}
.content-top-detail .title {
  font-size: 16px;
  line-height: 22px;
}
.content-top-detail .income {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.content-top-detail .income {
  margin-top: 22px;
}
.content-top-detail .income .income-item-title {
  font-size: 12px;
  line-height: 18px;
}
.content-top-detail .income .income-item-price {
  font-size: 22px;
  line-height: 26px;
  font-weight: bold;
}
.content-section {
  margin-top: 16px;
  padding: 8px 0;
}
.content-section .section-title {
  position: relative;
  font-size: 16px;
  line-height: 22px;
  margin-bottom: 16px;
  font-weight: bold;
}
.section-more {
  position: absolute;
  right: 0;
  top: 2px;
  font-size: 12px;
  line-height: 18px;
  color: #999999;
  font-weight: normal;
}
.section-more img {
  position: relative;
  top: 1px;
  width: 12px;
  height: 12px;
}
.section-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}
.section-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 33.33%;
}
.section-item .section-item-img {
  width: 45px;
  margin-bottom: 8px;
}
.section-item .section-item-txt {
  font-size: 12px;
  line-height: 18px;
} 
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #ECECEC;
}
.list-title {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.list-price {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.list-price .list-price-top {
  color: #999999;
  font-size: 12px;
  line-height: 18px;
}
.list-price .list-price-bottom {
  font-size: 16px;
  line-height: 24px;
}
</style>
